﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoyoEden.Models;

namespace CoyoEden.Web.Controls
{
	/// <summary>
	/// Category View Base
	/// </summary>
	public class CategoryViewBase:ViewBase
	{
		#region properties
		/// <summary>
		/// Category
		/// </summary>
		public Category TheCategory { get; set; }
		public List<Post> PostsShow { get; set; }
		public List<Category> CategoriesShow { get; set; }
		#endregion


		#region Readonly Properties
		/// <summary>
		/// 
		/// </summary>
		public List<Post> Posts {
			get {
				var items = Post.GetPostsByCategory(TheCategory.Id);
				return items;
			}
		}
		/// <summary>
		/// Whether has sub category
		/// </summary>
		public bool HasChildren {
			get {
				var items = Category.GetChildren(TheCategory);
				if (items != null && items.Count > 0) return true;
				return false;
			}
		}
		#endregion
	}
}
